package com.fengye.serialization.common;


import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fengye.common.CommonUtil;

import java.io.IOException;
import java.util.Date;

/**
 * @Author fengye
 * @Date 2023/2/13 9:41
 **/
public class FDateJsonSerializer extends JsonSerializer<Date> {

    @Override
    public void serialize(Date date, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
        jsonGenerator.writeString(date != null ? CommonUtil.FAST_DATE_FORMAT.format(date) : "null");
    }
}
